﻿using System;
using System.Collections.Generic;
using Baik.Interface.Execution;
using Baik.Interface.Expression;
using Baik.Interface.Framework;
using IUndefined = Baik.Interface.Execution.IUndefined;

namespace Baik.Execution
{
    public class BuiltInFunction :  IBuiltInFunction
    {
        public IInjector Inject { get; private set; }
        public BuiltInFunction(IInjector inject)
        {
            Inject = inject;
        }
        public Func<IEnumerable<IObject>,  IObject> Method { get;  set; }
        public IScope HostingScope { get; set; }
        public IObject Call(IEnumerable<IObject> prms)
        {
            return Method(prms);
        }

        public IEnumerable<IReference> Params { get; set; }
        public IEnumerable<IExpression> Expressions { get; set; }

        public IEnumerable<IScope> Parents { get; set; }
        public IScope DeclarationScope { get; set; }
        public bool TryGet(string name, out IObject val)
        {
            val = null;
            return false;
        }
        public string AsString()
        {
            return "BUILTIN";
        }

        public IObject Get(string name)
        {
            return Inject.Instantiate<IUndefined>();
        }

        public IArray GetAllMembers()
        {
            return Inject.Instantiate<IArray>();
        }

        public void Assign(string name, IObject value)
        {
            /*do nothing there is nothing to assign*/
        }

        public string Name { get; set; }
        public void Assign()
        {
            /*do nothing*/
        }
        public void DeAssign()
        {
            /*do nothing*/
        }
        public void Inherit(IObject parent)
        {
            /*do nothing*/
        }
    }
}